<template>
	<view>
		<view v-for="(item,index) in InfoList" :key="index">
			<uni-card>
				<view style="font-size: 16px;color:#303133;" >
					{{item.aname}}
				</view><br>
				<view style="font-size: 14px;color:#303133;" >
					被考核人：{{item.name}}
				</view><br>
				<view>
					考核时间：{{item.time}}
				</view>
				<view>
					<view v-if="item.status == 1">
						<view style="color: #18BC37;">已完成评分</view>
					</view>
					<view v-else>
						<view style="color: #E43D33;">待我评分</view>
					</view>
				</view>
			</uni-card>
			<view v-if="item.status == 1">
				<uni-card title="考核指标明细" >
					<view style="font-size: 14px;color:#303133;" >
						业绩指标：工作完成率
					</view><br>
					<view style="font-size: 14px;color:#303133;" >
						指标规则：90%及以上，100分；70%-90%，80分；60%-70%，60分；60%以下，50分
					</view><br>
					<view style="font-size: 14px;color:#303133;" >
						评分：{{item.score}}
					</view><br>
					<view style="font-size: 14px;color:#303133;" >
						评语：{{item.comment}}
					</view><br>
					<view style="font-size: 14px;color:#303133;" >
						评分人：{{item.rater}}
					</view><br>
				</uni-card>
			</view>
			<view v-else>
				<uni-card title="考核指标明细" >
					<view style="font-size: 14px;color:#303133;" >
						业绩指标：工作完成率
					</view><br>
					<view style="font-size: 14px;color:#303133;" >
						指标规则：90%及以上，100分；70%-90%，80分；60%-70%，60分；60%以下，50分
					</view><br>
					<span style="position: relative;">评分：</span>
					<uni-easyinput  v-model="user.score"></uni-easyinput>
					<span style="position: relative;">评语：</span>
					<uni-easyinput  v-model="user.comment"></uni-easyinput>
					<span style="position: relative;">评分人：</span>
					<uni-easyinput  v-model="user.rater"></uni-easyinput>
					<u-button type="primary" text="评分" style="width: 120px;margin-left: 32%;margin-top: 30px;" @click="comment(aid)"></u-button>
				</uni-card>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				aid:'',
				InfoList:{},
				user:{
					score:'',
					comment:'',
					rater:''
				}
			}
		},
		onLoad(res) {
			this.aid=res.aid
			console.log(this.aid)
			this.getByid()
			
		},
		methods: {
			getByid(){
				uni.request({
					url:'http://localhost:9525/performance/achievements/getByid?aid='+ this.aid,
					method:'GET',
					success:(res)=>{
						this.InfoList=res.data.data.list
						console.log(res.data.data.list)
					}
				})
			},
			comment(){
				uni.request({
					url:'http://localhost:9525/performance/achievements/comment',
					method: 'POST',
				   data: {
					   aid:this.aid,
					   score:this.user.score,
					   comment:this.user.comment,
					   rater:this.user.rater,
				   },
				   dataType:'json',
				   success: (res) => {
						// var result = JSON.parse(res.data.data.message);
						var result = res.data.message;
						console.log(res.data.data.i)
						uni.navigateTo({
							url:"/pages/index/Chenhongyu/performance/MyPerformance"
						})
					   },
					   
				
				})
			}
			
			
		}
	}
</script>

<style>

</style>
